<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@page import="com.globalresources.commons.Constant" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head><title>List Files</title></head>
	<script language="JavaScript">
	</script>
	<style type="text/css">
	<!--
	body {
		margin-left: 0px;
		margin-top: 0px;
		margin-right: 0px;
		margin-bottom: 0px;
		background-color: #EEF2FB;
	}
	-->
</style>
	<link href="../images/skin.css" rel="stylesheet" type="text/css" />
	<SCRIPT type="text/javascript">
		function selectAll(){	
			var _cb = document.getElementById('select_all');
			var checkboxes = document.getElementsByTagName("input");
			for(var i=0; i<checkboxes.length; i++){
				var checkbox = checkboxes[i];
				if(checkbox.id != 'select_all' && checkbox.type == 'checkbox'){
				 	checkbox.checked = _cb.checked;
				}
			}
		}
		function splitDocument(){
			var filenames = "";
			var checkboxes = document.getElementsByTagName("input");
			var aflag = true;
			var String
			for(var i=0; i<checkboxes.length; i++){
				var checkbox = checkboxes[i];
				if(checkbox.id != 'select_all' && checkbox.type == 'checkbox'){
				 	if(checkbox.checked == true){
				 		if(aflag == true){
				 			filenames =  checkbox.id;
				 		}else{
				 			filenames = filenames + "#spliter#" + checkbox.id;
				 		}
				 		aflag = false;
				 		
				 	}
				}
			}
			
			if(aflag){
				alert("Please Select Document!");
			}else{
				var form = document.createElement('form');
				form.setAttribute('method','post');
				form.setAttribute('action','splitDocument.action');
				var input = document.createElement('input');
				input.setAttribute('type','hidden');
				input.setAttribute('name','filenames');
				input.setAttribute('value',filenames);
				
				var input2 = document.createElement('input');
				input2.setAttribute('type','hidden');
				input2.setAttribute('name','hospitalFolder');
				input2.setAttribute('value','<s:property value="hospitalFolder"/>');
				
				form.appendChild(input);
				form.appendChild(input2);
				document.body.appendChild(form);
				form.submit();
			}
		}
		function operateDocument(){
			var filenames = "";
			var checkboxes = document.getElementsByTagName("input");
			var aflag = true;
			var String
			for(var i=0; i<checkboxes.length; i++){
				var checkbox = checkboxes[i];
				if(checkbox.id != 'select_all' && checkbox.type == 'checkbox'){
				 	if(checkbox.checked == true){
				 		if(aflag == true){
				 			filenames =  checkbox.id;
				 		}else{
				 			filenames = filenames + "#spliter#" + checkbox.id;
				 		}
				 		aflag = false;
				 		
				 	}
				}
			}
			
			if(aflag){
				alert("Please Select Document!");
			}else{
				var form = document.createElement('form');
				form.setAttribute('method','post');
				form.setAttribute('action','operateDocument.action');
				var input = document.createElement('input');
				input.setAttribute('type','hidden');
				input.setAttribute('name','filenames');
				input.setAttribute('value',filenames);
				form.appendChild(input);
				document.body.appendChild(form);
				form.submit();
			}
		}
	</SCRIPT>
<body>
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td>
			 <table width="100%" border="0" cellpadding="0" cellspacing="0">
			 	<tr>
			 		<td width="17" valign="top" background="../images/mail_leftbg.gif"><img src="../images/left-top-right.gif" width="17" height="29" /></td>
				    <td colspan="4" valign="top" background="../images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
				      <tr>
				        <td height="31"><s:property value="hospitalFolder"/> Documents&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="list.action"/>Back to Hospital List</a></td>
				      </tr>
				    </table></td>				    				    
				    <td width="16" valign="top" background="../images/mail_rightbg.gif"><img src="../images/nav-right-bg.gif" width="16" height="29" /></td>
			 	</tr>
			 
			 </table>
			</td>			
		</tr>
		<tr>
			<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F7F8F9">
						
						<thead>
							<tr>
								<th width="17" background="../images/mail_leftbg.gif"><img src="../images/mail_leftbg.gif" width="17" height="17" /></th>
								<th align="left">
									Select <input id="select_all" type="checkbox" onclick="selectAll();">
								</th>							
								<th align="left">
									Document Name
								</th>
								<th align="left">
									Receive Time
								</th>
								<th align="left">
								    Elapsed Time
								</th>
								<th align="left">
									IsSplit
								</th>
								<th align="left"> 
									Manage
								</th>
								<th width="16" background="../images/mail_rightbg.gif"><img src="../images/mail_rightbg.gif" width="16" height="17" /></th>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="under_filewrappers">
								<tr>
									<td width="17" background="../images/mail_leftbg.gif"><img src="../images/mail_leftbg.gif" width="17" height="17" /></td>
									<td align="left">
										<input id="<s:property value="parent" /><%=Constant.fs%><s:property value="name" />" type="checkbox">
									</td>
									<td align="left">
										<s:property value="name" />
									</td>
									<td align="left">
										<s:date name="lastModified" format="yyyy-MM-dd HH:mm:ss"/>										
									</td>
									<td>
										<s:property value="distance" /> Hours
									</td>
									<td>\
										
									</td>
									<td align="left">
										<a href="<s:url value="edit.action">
											<s:param name="documentName" value="name"/>
											<s:param name="createTime"><s:date name="lastModified" format="yyyyMMddHHmmssSSS"/></s:param>
										</s:url>">Operate</a>
									</td>
									<td width="16" background="../images/mail_rightbg.gif"><img src="../images/mail_rightbg.gif" width="16" height="17" /></td>									 
								</tr>
							</s:iterator>
							<tr align="right">
								<td width="17" background="../images/mail_leftbg.gif"><img src="../images/mail_leftbg.gif" width="17" height="17" /></td>
								<td align="left"><a href="javascript:splitDocument();">split</a>&nbsp;<a href="javascript:operateDocument();">operate</a></td>
								<td colspan="5">
								     A total of <s:property value="under_totalRow" /> rows
								    &nbsp; The <s:property value="under_currentPage" />th page
								    &nbsp; A total of <s:property value="under_pager.getTotalPages()" /> pages
								    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								    <a href="<s:url value="listFile.action">
    			                    	<s:param name="currentPage" value="under_currentPage"/>
    			                    	<s:param name="folder" value="folder"/>
    			                   	 	<s:param name="pagerMethod" value="'first'"/>
       								</s:url>">First Page</a>
									<a href="<s:url value="listFile.action">
    									<s:param name="currentPage" value="under_currentPage"/>
    									<s:param name="folder" value="folder"/>
    									<s:param name="pagerMethod" value="'previous'"/>
    								</s:url>">Pre Page</a>
									<a href="<s:url value="listFile.action">
    									<s:param name="currentPage" value="under_currentPage"/>
    									<s:param name="folder" value="folder"/>
    									<s:param name="pagerMethod" value="'next'"/>
    								</s:url>">Next Page</a>
									<a href="<s:url value="listFile.action">
    									<s:param name="currentPage" value="under_currentPage"/>
    									<s:param name="folder" value="folder"/>
    									<s:param name="pagerMethod" value="'last'"/>
    								</s:url>">Last Page</a>
								</td>
								<td width="16" background="../images/mail_rightbg.gif"><img src="../images/mail_rightbg.gif" width="16" height="17" /></td>
							</tr>

						</tbody>
					</table>
			</td>
		</tr>
		<tr>
			<td>
			 <table width="100%" border="0" cellpadding="0" cellspacing="0">
			 	<tr>
			 		<td width="17" valign="top" background="../images/mail_leftbg.gif"><img src="../images/buttom_left2.gif" width="17" height="17" /></td>
				    <td valign="top" background="../images/buttom_bgs.gif"><img src="../images/buttom_bgs.gif" width="17" height="17"></td>
				    <td width="16" valign="top" background="../images/mail_rightbg.gif"><img src="../images/buttom_right2.gif" width="16" height="17" /></td>
			 	</tr>
			 </table>
			</td>    
		</tr>
	</table>
</body>
</html>
